package com.maxsalad.uc.controller;

import com.maxsalad.uc.dao.OrderDao;
import com.maxsalad.uc.dto.DOrderDto;
import com.maxsalad.uc.pojo.ResponseResult;
import com.maxsalad.uc.pojo.TShopEntity;
import com.maxsalad.uc.service.OrderService;
import com.maxsalad.uc.service.ShopService;
import org.apache.commons.collections4.MapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * Created by 2014-400 on 2016-01-26.
 */
@RequestMapping(value = "/order")
@RestController
public class OrderController extends BaseController {
    private static final Logger log = LoggerFactory.getLogger(OrderController.class);

    @Autowired
    private OrderService orderService;

    @RequestMapping(value = "", method = RequestMethod.GET)
    public ResponseResult queryAllDish(@RequestParam Map paramMap) {
        try {
            DOrderDto dto = new DOrderDto();
            dto.setPlatformId(MapUtils.getLongValue(paramMap, "platformId", 0L));
            dto.setShopId(MapUtils.getLongValue(paramMap, "shopId", 0L));
            dto.setContactName(MapUtils.getString(paramMap, "contactName"));
            dto.setContactTel(MapUtils.getString(paramMap, "contactTel"));
            dto.setContactAddress(MapUtils.getString(paramMap, "contactAddress"));
            dto.setStatus(MapUtils.getString(paramMap, "status"));
            dto.setStartOrderTime(MapUtils.getLongValue(paramMap, "startOrderTime", 0L));
            dto.setEndOrderTime(MapUtils.getLongValue(paramMap, "endOrderTime", 0L));

            Map map = orderService.queryAllOrder(dto);
            return getSucResultData(map);
        } catch (Exception e) {
            e.printStackTrace();
            log.error(e.getMessage());
        }

        return getFaultMessage();
    }
}
